import { createRouter, createWebHistory,} from 'vue-router';



const routes = [
  {
    path: "/",
    name: 'home',
    component: () => import("../views/Index.vue"),
    children:[
      {
        path: "/res",
        name: 'res',
        component: () => import("../views/Res.vue"),
      },
      {
        path: "/emp",
        name: 'emp',
        component: () => import("../views/emp.vue"),
      },
      {
        path: "/cu",
        name: 'cu',
        component: () => import("../views/CreateUser.vue"),
      },
      {
        path: "/source",
        name: 'source',
        component: () => import("../views/AddSource.vue"),
      },
      {
        path: "/role",
        name: 'role',
        component: () => import("../views/RoleList.vue"),
      },
      {
        path: "/wf",
        name: 'wf',
        component: () => import("../views/Workflow.vue"),
      },
      {
        path: "/pwf",
        name: 'pwf',
        component: () => import("../views/PWF.vue"),
      },
      {
        path: "/eawf",
        name: 'eawf',
        component: () => import("../views/EAWF.vue"),
      },
    ]

},{
  path: "/login",
  name: 'login',
  component: () => import("../views/Login.vue"),
},

];















const router = createRouter({
  // history: createWebHistory(process.env.BASE_URL),
  history: createWebHistory(),
  routes
});



// router.beforeEach((to, from, next) => {
//   var reslist = ['/login','/']
//   if (reslist.indexOf(to.path) == -1) {
//       var token = localStorage.getItem('token')
//       if (token) {
//           //验证是否在权限列表中
//           var menulist = JSON.parse(localStorage.getItem('page_list'))
//           if (menulist) {
//               var mlist = menulist
//               if (mlist.indexOf(to.path) >= 0) {
//                   next()
//               } else {
//                   alert("无权访问此页面")
//                   next({ "name": 'login' })
//               }
//           } else {
//               alert("无权访问")
//           }

//       } else {
//           next({ "name": 'login' })
//       }
//   }else {
//       next()
//   }
// })



export default router;